Methods for automatic linear models for data frames of class design
lm(formula, ...)
# S3 method for default
lm(formula, data, subset, weights, na.action, method = "qr",
model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE,
contrasts = NULL, offset, ...)
# S3 method for design
lm(formula, ..., response=NULL, degree=NULL, FUN=mean,
use.center=NULL, use.star=NULL, use.dummies=FALSE)
aov(formula, ...)
# S3 method for default
aov(formula, data = NULL, projections = FALSE, qr = TRUE,
contrasts = NULL, ...)
# S3 method for design
aov(formula, ..., response=NULL, degree=NULL, FUN=mean,
use.center=FALSE)
# S3 method for lm.design
print(x, ...)
# S3 method for lm.design
summary(object, ...)
# S3 method for lm.design
coef(object, ...)
# S3 method for summary.lm.design
print(x, ...)
# S3 method for aov.design
print(x, ...)
# S3 method for aov.design
summary(object, ...)
# S3 method for summary.aov.design
print(x, ...)
lm.design
summary.lm.design
aov.design
summary.aov.design
The value for the lm
functions is a linear model object,
exactly like for function lm
,
except for the added class lm.design
in case of the method for class design
,
and an added list element WholePlotEffects
for split plot designs.
The value for the aov
functions is an aov object,
exactly like for function aov
,
and an added list element WholePlotEffects
for split plot designs.
The value of the summary
functions for class lm.design
and
aov.design
respectively
is a linear model or aov summary, exactly like documented in summary.lm
or summary.aov
,
except for the added classes summary.lm.design
or summary.aov.design
,
and an added list element WholePlotEffects
(for summary.lm.design
)
or attribute (for summary.aov.design
) for split plot designs.
The print functions return NULL
; they are used for their side effects only.
for the default method, cf. documentation for lm
in package stats;cr
for the class design
method, a data frame of S3 class
design
further arguments to functions lm
,
print.lm
or print.summary.lm
character string giving the name of the response variable
(must be among the responses of x
;
for wide format repeated measurement or parameter designs,
response
can also be among the column names of the responselist
element of the design.info
attribute)
OR
integer number giving the position of the response in element
response.names
of attribute design.info
For the default NULL
, the first available response variable
is used; for wide format designs, this is an aggregation of the variables
given in first column from the responselist
element of the design.info
attribute of x
.
degree for the formula; if NULL
,
the default for the formula
method is used
function for the aggregate.design
method;
this must be an unquoted function name;
This option is relevant for repeated measurement designs
and parameter designs in long format only
NULL
or logical indicating whether center points are to be used +
in the analysis;
if NULL
, the default is FALSE for pb
and FrF2
designs with
center points and TRUE for ccd
designs; the option is irrelevant
for all other design types.
FALSE
allows usage of simple analysis functions from package
FrF2-package
(e.g. function IAPlot
)
NULL
or logical indicating whether the star portion of a CCD design
is to be used in the analysis (ignored for all other types of designs).
The default TRUE analyses the complete design. Specifying FALSE permits interim analyses of
the cube portion of a central composite design.
logical indicating whether the error dummies of a Plackett Burman design are to be used in the formula (ignored for all other types of designs).
logical indicating whether the projections should be returned; for orthogonal arrays, these are helpful, as they provide the estimated deviation from the overall average attributed to each particular factor; it is not recommended to use them with unbalanced designs
object of class lm
or summary.lm
,
for lm.default
like in lm
object of class lm.design
created by function lm.design
a class that is identical in content to class lm
;
its purpose is to call a specific print method that provides slightly more
detail than the standard printout for linear models
a class that is identical in content to class summary.lm
;
its purpose is to call a specific print method that provides slightly more
detail than the standard summary for linear models
like in lm
like in lm
like in lm
like in lm
like in lm
like in lm
like in lm
like in lm
like in lm
like in lm
like in lm
The generics for lm
and aov
replace the functions
from package stats. For normal use, this is not an issue, because their
default methods are exactly the functions from package stats.
However, when programming on the language (or when using a package that relies on
such constructs), you may see unexpected results.
For example, match.call(lm)
returns a different result, depending on
whether or not package DoE.base is loaded. This can be avoided by
explicitly requesting e.g. match.call(stats::lm)
, which always works
in the same way.
Please report any additional issues that you may experience.
Ulrike Groemping
The aov
and lm
methods for class design
conduct a default linear model analysis for data frames of
class design
that do contain at least one response.
The intention for providing default analyses is to support convenient quick inspections. In many cases, there will be good reasons to customize the analysis, for example by including some but not all effects of a certain degree. Also, it may be statistically more wise to work with mixed models for some types of design. The default analyses must not be taken as a statistical recommendation!
The choice of default analyses
has been governed by simplicity: It uses fixed effects only and does either
main effects models (degree=1
, default for pb
and oa
designs),
models with main effects and 2-factor interactions (degree=2
,
default for most designs) or second order models (that contain
quadratic effects in addition to the 2-factor interactions, unchangeable default
for designs with quantitative variables). The degree
parameter can be used
to modify the degree of interactions. If blocks are
present, the block main effect is always entered as a fixed effect without interactions.
Designs with center points are per default analysed without the center points; the main
reason for this is convenient usage of functions DanielPlot
,
MEPlot
and IAPlot
from package FrF2.
With the use.center
option, this default can be changed; in this case, significance
of the center point indicator implies that there are one or more quadratic effect(s)
in the model.
Designs with repeated measurements (repeat.only=TRUE
) and parameter
designs of long format are treated by aggregate.design
with aggregation function FUN
(default: means are calculated)
before applying a linear model.
For designs with repeated measurements (repeat.only=TRUE
) and parameter
designs of wide format, the default is to use the first aggregated response,
if the design has been aggregated already. For a so far unaggregated design,
the default is to treat the design by aggregate.design
,
using the function FUN
(default: mean) and then use the first response.
The defaults can be overridden by specifying response
: Here,
response
can not only be one of the current responses but also a column name
of the responselist
element of the design.info
attribute of the
design (i.e. a response name from the long version of the design).
The implementation of the formulae is not done in functions lm.design
or
aov.design
themselves
but based on the method for function formula (formula.design
).
The print
methods prepend the formula and the number of experimental runs
underlying the analysis to the default printout.
The purpose of this is meaningful output in case a call from
inside function lm.design
or aov.design
(methods for functions lm
and aov
)
does not reveal enough information, and another pointer that center points have been
omitted or repeated measurements aggregated over. The coef
method for objects
of class lm.design
suppresses NA
coefficients, i.e.
returns valid coefficients only. For aov
objects, this is the default
anyway.
See also the information on class design
and its formula method formula.design
oa12 <- oa.design(nlevels=c(2,2,6))
## add a few variables to oa12
responses <- cbind(y=rexp(12),z=runif(12))
oa12 <- add.response(oa12, responses)
## want treatment contrasts rather than the default
## polynomial contrasts for the factors
oa12 <- change.contr(oa12, "contr.treatment")
linmod.y <- lm(oa12)
linmod.z <- lm(oa12, response="z")
linmod.y
linmod.z
summary(linmod.y)
summary(linmod.z)
## examples with aggregation
plan <- oa.design(nlevels=c(2,6,2), replications=2, repeat.only=TRUE)
y <- rnorm(24)
z <- rexp(24)
plan <- add.response(plan, cbind(y=y,z=z))
lm(plan)
lm(plan, response="z")
lm(plan, FUN=sd)
## wide format
plan <- reptowide(plan)
plan
design.info(plan)$responselist
## default: aggregate variables for first column of responselist
lm(plan)
## request z variables instead (z is the column name of response list)
lm(plan, response="z")
## force analysis of first z measurement only
lm(plan, response="z.1")
## use almost all options
## (option use.center can only be used with center point designs
## from package FrF2)
summary(lm(plan, response="z", degree=2, FUN=sd))
Run the code above in your browser using DataLab